add service account id as option to register agentex agent#332
Merged
alvinkam2001 merged 2 commits intonextfrom Apr 30, 2026
Merged
add service account id as option to register agentex agent#332alvinkam2001 merged 2 commits intonextfrom
alvinkam2001 merged 2 commits intonextfrom
Conversation
declan-scale
approved these changes
Apr 27, 2026
Contributor
|
Updated the base to next, in this package we should always pr against next |
16ab771 to
f17ad00
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Relaxes the
environments.yamlauth-principal validator so agent developers can register an agent under a service account instead of a user identity._validate_single_environment_confignow requires exactly one ofuser_idorservice_account_idin theauth.principalblock (mutually exclusive). The previous validator hard-requireduser_id, which blocked SA registration end-to-end.environment_config.pyto show both shapes.Backwards compatible: existing configs with only
user_idcontinue to validate. Field shape mirrors whatagentex-auth(SGPPrincipalContext) and SGP (x-user-id/x-service-account-idheaders) already use, so no translation layer is needed between yaml and the wire.Related PRs (ship together)
scaleapi/scale-agentex-python#332Test Plan
tests/lib/cli/test_validation.py, all passing viauv run pytest:test_environment_config.py(18 tests) still passes.ruff check+ruff formatclean.Greptile Summary
This PR relaxes the
environments.yamlauth-principal validator to accept eitheruser_idorservice_account_id(mutually exclusive), enabling agents to be registered under a service account identity. Existing configs using onlyuser_idare fully backwards-compatible, and four targeted unit tests cover all four principal combinations.Confidence Score: 5/5
Safe to merge — change is backwards-compatible, logic is correct, and all four principal scenarios are tested.
The only finding is a P2 style suggestion (missing explanatory comment) that does not affect correctness or runtime behavior. All changed paths are covered by new tests.
No files require special attention.
Important Files Changed
user_idwith a mutually-exclusiveuser_idXORservice_account_idcheck; error messages and hints updated accordingly. Logic is correct and backwards-compatible.service_account_idYAML example toget_configs_for_env. No model or validation logic changed.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[_validate_single_environment_config] --> B{principal has user_id?} B -- No --> C{principal has service_account_id?} C -- No --> D[❌ ValueError: must contain one of user_id or service_account_id] C -- Yes --> E[✅ SA path — skip env-name warning] B -- Yes --> F{also has service_account_id?} F -- Yes --> G[❌ ValueError: not both] F -- No --> H{user_id is a string?} H -- Yes --> I{contains env indicator?} I -- No --> J[⚠️ logger.warning: missing env indicator in user_id] I -- Yes --> K[✅ user_id path OK] J --> K E --> L[validate helm overrides if present] K --> LComments Outside Diff (1)
src/agentex/lib/sdk/config/validation.py, line 239-245 (link)service_account_idThe hint block is triggered whenever
"user_id"appears in the error message. Both new error messages ("must contain non-empty 'user_id' or 'service_account_id'"and"must contain only one of 'user_id' or 'service_account_id', not both") contain the string"user_id", so this block fires forservice_account_id-related failures too — but the tips text mentions onlyuser_id, which will mislead users configuring a service account principal.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "better error message" | Re-trigger Greptile
Context used:
Learned From
scaleapi/scaleapi#126958